package com.yasaka.stock.common;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;
import org.xm.xmnlp.Xmnlp;
import org.xm.xmnlp.corpus.tag.Nature;
import org.xm.xmnlp.seg.Segment;
import org.xm.xmnlp.seg.domain.Term;

@Component
public class TXMNLP {

	public static Segment segment = Xmnlp.newSegment().enableNameRecognize(true)
			.enableCustomDictionary(false).enableJapaneseNameRecognize(true)
			.enableAllNamedEntityRecognize(true).enableMultithreading(true)
			.enableNumberQuantifierRecognize(true)
			.enableOrganizationRecognize(true).enablePlaceRecognize(true)
			.enableTranslatedNameRecognize(true);


	public static List<String> getTermforNature(String aText, Nature aNature) {
		List<String> mResult = new ArrayList<String>();
		for (Term mterm : segment.seg(aText)) {
			if (mterm.nature == aNature)
				if (!mResult.contains(mterm.word))
					mResult.add(mterm.word);
		}
		;
		return mResult;

	}

	public static List<String> getJapaneseName(String aText) {
//		if ("".equals(aText))
//			return new TWebResult(TApiState.API102, false);
//		TWebResult mResult = new TWebResult();
//		mResult.setResult(true);
		//mResult.setData(getTermforNature(aText, Nature.nrj));
		return getTermforNature(aText, Nature.nrj);
	}






}
